<script>
import { routeGuard } from './src/utils/auth'

export default {
	onLaunch: function() {
		console.log('App Launch')
		// 获取系统状态栏高度并设置全局 CSS 变量
		const systemInfo = uni.getSystemInfoSync()
		uni.setStorageSync('statusBarHeight', systemInfo.statusBarHeight)
		document.documentElement.style.setProperty('--status-bar-height', `${systemInfo.statusBarHeight}px`)
	},
	onShow: function() {
		console.log('App Show')
	},
	onHide: function() {
		console.log('App Hide')
	}
}

// 添加全局路由拦截
uni.addInterceptor('navigateTo', {
	invoke(e) {
		return routeGuard(e.url)
	}
})

uni.addInterceptor('switchTab', {
	invoke(e) {
		return routeGuard(e.url)
	}
})

uni.addInterceptor('reLaunch', {
	invoke(e) {
		return routeGuard(e.url)
	}
})
</script>

<style>
	/*每个页面公共css */
	/* 全局的公共样式 */
/* 	uni-page-body{
		height: 100%;
	} */

	/* 全局样式 */
	page {
		--status-bar-height: 0px;
	}

	.safe-area-container {
		min-height: 100vh;
		padding-top: var(--status-bar-height);
		box-sizing: border-box;
		position: relative;
	}

	.custom-nav-bar {
		position: fixed;
		top: var(--status-bar-height);
		left: 0;
		right: 0;
		z-index: 100;
		background-color: #fff;
	}

	.page-content {
		position: relative;
		z-index: 1;
	}
</style>
